﻿#include <QtCore>
#include <QtNetwork/QNetworkAccessManager>

///
#include "thirdparty/xml2json/include/xml2json.hpp"
namespace wechat {
void DecodeHeadImages();
void DecodeChatMessage();
void DecodeFavoriteMessage();
}  // namespace wechat

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    //设置工作目录到qtcreator，支持https，如果没生效需要手动拷贝ssl相关的两个库到运行目录, libcrypto-1_1.dll & libssl-1_1.dll
    QString creator_dir = R"(F:\Qt\Tools\QtCreator\bin\)";
    if (!QFile::exists(creator_dir)) {
      creator_dir[0]='D';
    }
    QDir::setCurrent(creator_dir);

    QNetworkAccessManager manager;
    if(!manager.supportedSchemes().join(',').contains("https")) {
      qWarning() << "please copy ssl library to current runtime path";
      return -1;
    }

    bool use_function = false;

    //导出界面头像数据
    if (false) {
        use_function = true;
        wechat::DecodeHeadImages();
    }

    //导出聊天记录，仅支持2016年前的微信聊天数据库
    if (false) {
        use_function = true;
        wechat::DecodeChatMessage();
    }

    //导出收藏夹，微信收藏的文件
    if (true) {
        use_function = true;
        wechat::DecodeFavoriteMessage();
    }

    if (!use_function) {
        qWarning() << "please modify define.h and if function";
    }
    return 0;//a.exec();
}
